﻿using System;
using System.Data;
using System.Linq;
using System.Windows.Forms;
using Spread.Common.Features.Sample;
using FarPoint.Win.Spread;
using Spread.Common.DataStore;

namespace Spread.WorkBook.Features
{
    public partial class StatusBarDemo : BaseSampleControl
    {
        public StatusBarDemo()
        {
            InitializeComponent();
            InitializeControls();
            SetupSpreadSheet();
        }
        private void InitializeControls()
        {
            Name = "Status Bar";
            skinComboBox.DataSource = typeof(StatusBarDefaultSkin).GetFields().Select(x=>x.Name).ToList();
        }
        private void SetupSpreadSheet()
        {
            spread.StatusBarVisible = true;
            spread.StatusBar.EnableContextMenu = true;
            spread.StatusBar.Skin = StatusBarDefaultSkin.ArcticSeaStatusBarSkin;
            sheetView.DataAutoSizeColumns = false;
            sheetView.Columns.Default.Width = 90;
            sheetView.Rows.Default.Height = 25;
            sheetView.DataSource = new DataService().AccessDataSource.GetNWINDData("Products");
        }
        private void SkinComboBox_IndexChanged(object sender,EventArgs e)
        {
            spread.StatusBar.Skin = (StatusBarSkin) typeof(StatusBarDefaultSkin).GetField(skinComboBox.SelectedItem.ToString()).GetValue(null);
        }
        private void StatusBarColor_Changed(object sender,EventArgs e)
        {
            ColorDialog _color = new ColorDialog();
            _color.ShowDialog();
            typeof(IFpStatusBar).GetProperty((sender as Button).Tag.ToString()).SetValue(spread.StatusBar, _color.Color);
        }
    }
}


//
//StatusBarDemo.Designer.cs
//


namespace Spread.WorkBook.Features
{
    partial class StatusBarDemo
    {
        /// <summary> 
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            FarPoint.Win.Spread.FlatScrollBarRenderer flatScrollBarRenderer1 = new FarPoint.Win.Spread.FlatScrollBarRenderer();
            FarPoint.Win.Spread.FlatScrollBarRenderer flatScrollBarRenderer2 = new FarPoint.Win.Spread.FlatScrollBarRenderer();
            this.spread = new FarPoint.Win.Spread.FpSpread(FarPoint.Win.Spread.LegacyBehaviors.None);
            this.sheetView = new FarPoint.Win.Spread.SheetView();
            this.skinLabel = new System.Windows.Forms.Label();
            this.skinComboBox = new System.Windows.Forms.ComboBox();
            this.statusBarGroupBox = new System.Windows.Forms.GroupBox();
            this.zSliderHoverColor = new System.Windows.Forms.Button();
            this.zSliderTrackColor = new System.Windows.Forms.Button();
            this.zSliderColor = new System.Windows.Forms.Button();
            this.zbuttonHover = new System.Windows.Forms.Button();
            this.foreColorButton = new System.Windows.Forms.Button();
            this.backColorButton = new System.Windows.Forms.Button();
            this.pnlMain.SuspendLayout();
            this.pnlControls.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.spread)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.sheetView)).BeginInit();
            this.statusBarGroupBox.SuspendLayout();
            this.SuspendLayout();
            // 
            // pnlMain
            // 
            this.pnlMain.Controls.Add(this.spread);
            // 
            // pnlControls
            // 
            this.pnlControls.Controls.Add(this.statusBarGroupBox);
            this.pnlControls.Controls.Add(this.skinComboBox);
            this.pnlControls.Controls.Add(this.skinLabel);
            // 
            // spread
            // 
            this.spread.Dock = System.Windows.Forms.DockStyle.Fill;
            this.spread.Location = new System.Drawing.Point(0, 0);
            this.spread.Name = "spread";
            this.spread.Sheets.AddRange(new FarPoint.Win.Spread.SheetView[] {
            this.sheetView});
            this.spread.Size = new System.Drawing.Size(477, 487);
            this.spread.TabIndex = 0;
            // 
            // sheetView
            // 
            this.sheetView.Reset();
            this.sheetView.SheetName = "StatusBar";
            // Formulas and custom names must be loaded with R1C1 reference style
            this.sheetView.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.R1C1;
            this.sheetView.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.A1;
            // 
            // skinLabel
            // 
            this.skinLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.skinLabel.Location = new System.Drawing.Point(5, 15);
            this.skinLabel.Name = "skinLabel";
            this.skinLabel.Size = new System.Drawing.Size(144, 13);
            this.skinLabel.TabIndex = 0;
            this.skinLabel.Text = "Choose Skin";
            // 
            // skinComboBox
            // 
            this.skinComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.skinComboBox.FormattingEnabled = true;
            this.skinComboBox.Location = new System.Drawing.Point(5, 31);
            this.skinComboBox.Name = "skinComboBox";
            this.skinComboBox.Size = new System.Drawing.Size(144, 21);
            this.skinComboBox.TabIndex = 1;
            this.skinComboBox.SelectedIndexChanged += new System.EventHandler(this.SkinComboBox_IndexChanged);
            // 
            // statusBarGroupBox
            // 
            this.statusBarGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.statusBarGroupBox.Controls.Add(this.zSliderHoverColor);
            this.statusBarGroupBox.Controls.Add(this.zSliderTrackColor);
            this.statusBarGroupBox.Controls.Add(this.zSliderColor);
            this.statusBarGroupBox.Controls.Add(this.zbuttonHover);
            this.statusBarGroupBox.Controls.Add(this.foreColorButton);
            this.statusBarGroupBox.Controls.Add(this.backColorButton);
            this.statusBarGroupBox.Location = new System.Drawing.Point(5, 91);
            this.statusBarGroupBox.Name = "statusBarGroupBox";
            this.statusBarGroupBox.Size = new System.Drawing.Size(144, 248);
            this.statusBarGroupBox.TabIndex = 3;
            this.statusBarGroupBox.TabStop = false;
            this.statusBarGroupBox.Text = "Custom Status Bar";
            // 
            // zSliderHoverColor
            // 
            this.zSliderHoverColor.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.zSliderHoverColor.Location = new System.Drawing.Point(6, 210);
            this.zSliderHoverColor.Name = "zSliderHoverColor";
            this.zSliderHoverColor.Size = new System.Drawing.Size(132, 23);
            this.zSliderHoverColor.TabIndex = 5;
            this.zSliderHoverColor.Tag = "ZoomSliderHoverColor";
            this.zSliderHoverColor.Text = "ZoomSliderHoverColor";
            this.zSliderHoverColor.UseVisualStyleBackColor = true;
            this.zSliderHoverColor.Click += new System.EventHandler(this.StatusBarColor_Changed);
            // 
            // zSliderTrackColor
            // 
            this.zSliderTrackColor.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.zSliderTrackColor.Location = new System.Drawing.Point(6, 175);
            this.zSliderTrackColor.Name = "zSliderTrackColor";
            this.zSliderTrackColor.Size = new System.Drawing.Size(132, 23);
            this.zSliderTrackColor.TabIndex = 4;
            this.zSliderTrackColor.Tag = "ZoomSliderTrackColor";
            this.zSliderTrackColor.Text = "ZoomSliderTrackcolor\r\n";
            this.zSliderTrackColor.UseVisualStyleBackColor = true;
            this.zSliderTrackColor.Click += new System.EventHandler(this.StatusBarColor_Changed);
            // 
            // zSliderColor
            // 
            this.zSliderColor.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.zSliderColor.Location = new System.Drawing.Point(6, 140);
            this.zSliderColor.Name = "zSliderColor";
            this.zSliderColor.Size = new System.Drawing.Size(132, 23);
            this.zSliderColor.TabIndex = 3;
            this.zSliderColor.Tag = "ZoomSliderColor";
            this.zSliderColor.Text = "ZoomSliderColor";
            this.zSliderColor.UseVisualStyleBackColor = true;
            this.zSliderColor.Click += new System.EventHandler(this.StatusBarColor_Changed);
            // 
            // zbuttonHover
            // 
            this.zbuttonHover.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.zbuttonHover.Location = new System.Drawing.Point(6, 105);
            this.zbuttonHover.Name = "zbuttonHover";
            this.zbuttonHover.Size = new System.Drawing.Size(132, 23);
            this.zbuttonHover.TabIndex = 2;
            this.zbuttonHover.Tag = "ZoomButtonHoverColor";
            this.zbuttonHover.Text = "ZoomButtonHoverColor";
            this.zbuttonHover.UseVisualStyleBackColor = true;
            this.zbuttonHover.Click += new System.EventHandler(this.StatusBarColor_Changed);
            // 
            // foreColorButton
            // 
            this.foreColorButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.foreColorButton.Location = new System.Drawing.Point(6, 70);
            this.foreColorButton.Name = "foreColorButton";
            this.foreColorButton.Size = new System.Drawing.Size(132, 23);
            this.foreColorButton.TabIndex = 1;
            this.foreColorButton.Tag = "ForeColor";
            this.foreColorButton.Text = "ForeColor";
            this.foreColorButton.UseVisualStyleBackColor = true;
            this.foreColorButton.Click += new System.EventHandler(this.StatusBarColor_Changed);
            // 
            // backColorButton
            // 
            this.backColorButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.backColorButton.Location = new System.Drawing.Point(6, 35);
            this.backColorButton.Name = "backColorButton";
            this.backColorButton.Size = new System.Drawing.Size(132, 23);
            this.backColorButton.TabIndex = 0;
            this.backColorButton.Tag = "BackColor";
            this.backColorButton.Text = "Back Color";
            this.backColorButton.UseVisualStyleBackColor = true;
            this.backColorButton.Click += new System.EventHandler(this.StatusBarColor_Changed);
            // 
            // StatusBarDemo
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Name = "StatusBarDemo";
            this.pnlMain.ResumeLayout(false);
            this.pnlControls.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.spread)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.sheetView)).EndInit();
            this.statusBarGroupBox.ResumeLayout(false);
            this.ResumeLayout(false);

        }

        #endregion

        private FarPoint.Win.Spread.FpSpread spread;
        private FarPoint.Win.Spread.SheetView sheetView;
        private System.Windows.Forms.ComboBox skinComboBox;
        private System.Windows.Forms.Label skinLabel;
        private System.Windows.Forms.GroupBox statusBarGroupBox;
        private System.Windows.Forms.Button zSliderHoverColor;
        private System.Windows.Forms.Button zSliderTrackColor;
        private System.Windows.Forms.Button zSliderColor;
        private System.Windows.Forms.Button zbuttonHover;
        private System.Windows.Forms.Button foreColorButton;
        private System.Windows.Forms.Button backColorButton;
    }
}
